package com.crawler58;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;

import com.crawler58.entity.Base;
import com.crawler58.entity.Board;
import com.crawler58.service.FetchWorker;

public class Test {

	public static void main(String[] args) {
		
		/*BlockingQueue<Base> seedQueue = new SynchronousQueue<Base>();
		BlockingQueue<Base> listQueue = new SynchronousQueue<Base>();
		BlockingQueue<Base> detailQueue = new SynchronousQueue<Base>();
		
		FetchWorker seedWorker = new FetchWorker(seedQueue, listQueue, "E:\\workspace-win7\\Crawler58\\js\\58seed.js");
		FetchWorker listWorker = new FetchWorker(listQueue, detailQueue, "");
		FetchWorker detailWorker = new FetchWorker(detailQueue, null, "");
		
		seedWorker.start();
		listWorker.start();
		detailWorker.start();

		seedQueue.add(new Seed("lala", "http://bj.58.com/ershoujiaju/pn70/"));*/
		
		BlockingQueue<Base> boardQueue = new LinkedBlockingDeque<Base>(5);
		BlockingQueue<Base> detailQueue = new LinkedBlockingDeque<Base>(100);
		
		FetchWorker listWorker = new FetchWorker(boardQueue, detailQueue, "D:\\Workspaces-db-restructured\\Crawler58\\js\\58board.js");
		FetchWorker detailWorker = new FetchWorker(detailQueue, null, "D:\\Workspaces-db-restructured\\Crawler58\\js\\58detail.js");
		FetchWorker detailWorker1 = new FetchWorker(detailQueue, null, "D:\\Workspaces-db-restructured\\Crawler58\\js\\58detail.js");
		FetchWorker detailWorker2 = new FetchWorker(detailQueue, null, "D:\\Workspaces-db-restructured\\Crawler58\\js\\58detail.js");
		FetchWorker detailWorker3 = new FetchWorker(detailQueue, null, "D:\\Workspaces-db-restructured\\Crawler58\\js\\58detail.js");
		FetchWorker detailWorker4 = new FetchWorker(detailQueue, null, "D:\\Workspaces-db-restructured\\Crawler58\\js\\58detail.js");
		
		listWorker.start();
		detailWorker.start();
		detailWorker1.start();
		detailWorker2.start();
		detailWorker3.start();
		detailWorker4.start();

		boardQueue.add(new Board("lala", "http://bj.58.com/ershoujiaju/"));
		boardQueue.add(new Board("lala", "http://bj.58.com/ershoujiaju/pn1/"));
		boardQueue.add(new Board("lala", "http://bj.58.com/ershoujiaju/pn2/"));
		boardQueue.add(new Board("lala", "http://bj.58.com/ershoujiaju/pn3/"));
	}

}
